package task_server

import (
	"context"
	"cronjob_work/internal/dao"
	"cronjob_work/internal/model/entity"
	"cronjob_work/internal/service"
	"github.com/gogf/gf/v2/frame/g"
)

type sTaskServer struct {
}

func (s sTaskServer) UpdateStatus(ctx context.Context, serviceId int, status int) error {
	_, err := dao.PpTaskServer.Ctx(ctx).Where("id=?", serviceId).Update(g.Map{"status": status})
	return err
}

func (s sTaskServer) TaskServerGetById(ctx context.Context, serviceId int) (*entity.PpTaskServer, error) {
	var data *entity.PpTaskServer
	err := dao.PpTaskServer.Ctx(ctx).Where("id=?", serviceId).Scan(&data)
	return data, err
}

func init() {
	service.RegisterTaskServer(New())
}

func New() *sTaskServer {
	return &sTaskServer{}
}
